/*
 * @Author: zhangweixin 
 * @Date: 2018-11-20 10:44:22 
 * @Last Modified by: zhangweixin
 * @Last Modified time: 2018-11-20 11:28:13
 */

import {
  GET_USER_INFO_REQUEST,
  GET_USER_INFO_SUCCESS,
  GET_USER_INFO_FAIL
} from '../constants/actionTypes';

const initState={
  isLoading:false,
  userInfo:{},
  errorMsg:""
}

export default function reducer(state=initState, action){
  switch(action.type){
    case GET_USER_INFO_REQUEST:
      return {
        ...state,
        isLoading:true,
        userInfo:{},
        errorMsg:""
      }
    case GET_USER_INFO_SUCCESS:
      return {
          ...state,
          isLoading: false,
          userInfo: action.userInfo,
          errorMsg: ''
      };
    case GET_USER_INFO_FAIL:
      return {
          ...state,
          isLoading: false,
          userInfo: {},
          errorMsg: '请求错误'
      };
    default:
      return state;
  }
}
